var app = getApp()
Page({
  data: {
    phone:'',
    shenstr:'',
    yzm:''
  },
  onShareAppMessage: function (res) {
    let member_id = app.globalData.userInfo.member_id
    return {
      title: '成纪先锋微平台',
      path: '/pages/mine/login?inviter_id=' + member_id,
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      }
    }
  },
  onLoad: function (options) {
    app.login()
  },
  getshenfen(e){
    this.setData({
      shenstr: e.detail.value
    })
  },
  getphone(e){
    this.setData({
      phone:e.detail.value
    })
  },
  getyzmstr(e){
    this.setData({
      yzm: e.detail.value
    })
  },
  getyzm(){
    app.ajax("send_smsali", {phone:this.data.phone}, (data, err) => {
      
    })
  },
  //确认绑定
  login(){
    if(this.data.shenstr && this.data.phone && this.data.yzm){
      if (app.checkPhone(this.data.phone)){
        let par = {
          openid: wx.getStorageSync("openid"),
          idcard: this.data.shenstr,
          phone: this.data.phone,
          code: this.data.yzm
        }
        app.ajax("login", par, (data, err) => {
          wx.showToast({
            title: data.message,
          })
          if(data.result == 'success'){
            wx.setStorageSync("rd_session", data.data.rd_session)
            wx.navigateBack({})
          }
        })
      }else{
        wx.showToast({
          title: '手机号格式错误',
        })
      }
    }else{
      wx.showToast({
        title: '不能是空',
      })
    }
    
  },
  formSubmit2: function (e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
  },
  formReset2: function () {
    this.setData({
      editdialog: false
    })
  }
});